#include<bits/stdc++.h>
#define int long long
#define N 400005
#define M 105
#define INF 1e18
using namespace std;
const int mx=1e9;
int n,m,a[N],b[N],c[N],ans[N],k,X[5],sum,fans;
string s[N];
signed main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    srand(time(NULL));
    cin>>n>>m,k=log2(n);
    while((1ll<<k)<n) k++;
    while((1ll<<(k-1))>=n) k--;
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=m;i++) cin>>c[i];
    for(int i=1;i<=k;i++){
        cin>>s[i];
        s[i]=" "+s[i];
    }
    int T; cin>>T;
    while(T--){
        cout<<rand()%n+1<<endl;
    }
    return 0;
}